package com.cbs.java.component.network;

/**
 * Created by broche on 10/20/15.
 */
public abstract class Handler {
    public abstract void handleMessage(Message msg);

    public Message obtainMessage(int what, Object obj) {
        return new Message(what, obj, this);
    }

    class Message {
        public int what = 0;
        public Object obj = null;
        public Handler handler = null;

        public Message(int what, Object obj, Handler handler) {
            this.what = what;
            this.obj = obj;
            this.handler = handler;
        }

        public void sendToTarget() {
            handler.handleMessage(this);
        }
    }
}
